/*******************************************************************************
 * 
 * Copyright:
 * 
 * License:
 * 
 * Authors: SALMON Charles
 * 
 ******************************************************************************/

/*******************************************************************************
 * 
 ******************************************************************************/

/**
 * The GUI definition of the bip admin view
 */
qx.Class.define("bip.UserView", {
	extend : qx.ui.container.Composite,
	

	/*
	 * ****************************************************************************
	 * CONSTRUCTOR
	 * ****************************************************************************
	 */

	construct : function() {
		this.base(arguments);

		// Configure layout
		var layout = new qx.ui.layout.VBox;
		layout.setSeparator("separator-vertical");
		this.setLayout(layout);

		// Header
		this.add(this.__createHeader());

	  // Commands & Menu Bar
		this.__makeCommands();
		this.__menuBar = this.__makeToolBar();
		this.add(this.__menuBar);
		
		// Desktop
		this.__desktop = new qx.ui.window.Desktop();
		this.add(this.__desktop,{flex:1});
		
		if (! this.__winFillSurvey) {
			this.__winFillSurvey = new bip.ui.survey.WinFillSurvey();
			this.__desktop.add(this.__winFillSurvey);
		} 
		this.__winFillSurvey.open();
		//this.__winFillSurvey.maximize();

	},

	/*
	 * ****************************************************************************
	 * PROPERTIES
	 * ****************************************************************************
	 */

	properties : {

	},

	/*
	 * ****************************************************************************
	 * MEMBERS
	 * ****************************************************************************
	 */

	members : {
		__winFillSurvey:null,
		__desktop:null,
		
		// ------------------------------------------------------------------------
		// CONSTRUCTOR HELPERS
		// ------------------------------------------------------------------------
		/**
		 * Creates the application header.
		 */
		__createHeader : function() {
			var layout = new qx.ui.layout.HBox();
			var header = new qx.ui.container.Composite(layout);
			header.setAppearance("app-header");

			var title = new qx.ui.basic.Label("BIP [USER]");
			var user = bip.rpc.RpcManager.getInstance().getUserName();
			var userNameLabel = new qx.ui.basic.Label("user:" + user);

			header.add(title);
			header.add(new qx.ui.core.Spacer, {
				flex : 1
			});
			header.add(userNameLabel);

			return header;
		},
		
		__makeCommands : function() {
			/*this._cmdObjectSummary = new qx.ui.core.Command("Ctrl+O");
			this._cmdObjectSummary.addListener("execute",
					this.__getObjectSummary, this);

			this._cmdRunSample = new qx.ui.core.Command("F5");
			this._cmdRunSample.addListener("execute", this.runSample, this);

			this._cmdPrevSample = new qx.ui.core.Command("Ctrl+Left");
			this._cmdPrevSample.addListener("execute", this.playPrev, this);

			this._cmdNextSample = new qx.ui.core.Command("Ctrl+Right");
			this._cmdNextSample.addListener("execute", this.playNext, this);

			this._cmdSampleInOwnWindow = new qx.ui.core.Command("Ctrl+N");
			this._cmdSampleInOwnWindow.addListener("execute",
					this.__openWindow, this);

			this._cmdDisposeSample = new qx.ui.core.Command("Ctrl+D");
			this._cmdDisposeSample.addListener("execute", this.__disposeSample,
					this);

			this._cmdNamespacePollution = new qx.ui.core.Command("Ctrl+P");
			this._cmdNamespacePollution.addListener("execute",
					this.__showPollution, this);*/
		},
		
		__makeToolBar : function() {
			var bar = new qx.ui.toolbar.ToolBar();

		  
			return bar;
			
		}

	},

	/*
	 * ****************************************************************************
	 * DESTRUCTOR
	 * ****************************************************************************
	 */

	destruct : function() {
		this._disposeObjects("__winFillSurvey");
	}
});
